﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenTK;
using DDD.Core;
using DDD.OpenTK;
using FloatComparer = DDDTest.Helper.FloatComparer;

namespace DDDTest.OpenTK.TestVertexArray {
    [TestClass]
    public class TestCapture_short_short2_short3_short4_ {

        #region Field
        GameWindow window;
        #endregion

        #region Setup
        [TestInitialize ()]
        public void MyClassInitialize () {
            window = new GameWindow ();
        }

        [TestCleanup ()]
        public void MyClassCleanup () {
            window.Dispose ();
            window = null;
        }
        #endregion

        #region TestMethod
        [TestMethod]
        public void Test_Capture_short () {
            var pos = new short[2] { -1, 1 };
            var varry = new VertexArray<short> (2, 1);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new short[2];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void Test_Capture_short2 () {

            var pos = new short[4] { -1, 0, 1, 2 };
            var varry = new VertexArray<short> (2, 2);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new short[4];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void Test_Capture_short3 () {

            var pos = new short[6] { -1, 0, 1, 2, 3, 4 };
            var varry = new VertexArray<short> (2, 3);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new short[6];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }

        [TestMethod]
        public void Test_Capture_short4 () {

            var pos = new short[8] { -1, 0, 1, 2, 3, 4, 5, 6 };
            var varry = new VertexArray<short> (2, 4);
            varry.Set (0, 2, pos);

            varry.Compile ();
            varry.Clear ();
            varry.Capture ();

            var buf = new short[8];
            varry.Get (0, 2, buf);

            CollectionAssert.AreEqual (pos, buf);
        }
        #endregion

    }
}
